package com.myaihui.controller.admin;

import com.myaihui.domain.Park;
import com.myaihui.foundation.model.Pager;
import com.myaihui.foundation.query.ParkQuery;
import com.myaihui.foundation.vo.ParkPageVo;
import com.myaihui.service.ParkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * *******************************
 * Created by Tim.
 * form com.myaihui
 * on 2018/5/31
 * *******************************
 */
@RequestMapping(value = "/park")
@Controller
public class ParkController {

    @Autowired
    private ParkService parkService;


    @RequestMapping(value = "/")
    public ModelAndView home(Integer type, String marketId, String propertyMgrId){
        ModelAndView modelAndView = new ModelAndView("park/home");
        modelAndView.addObject("type", type);
        modelAndView.addObject("marketId", marketId);
        modelAndView.addObject("propertyMgrId", propertyMgrId);
        return modelAndView;
    }

    @RequestMapping(value = "/page")
    public Pager<ParkPageVo> page(ParkQuery parkQuery){
        return parkService.getParkPage(parkQuery);
    }

    @RequestMapping(value = "/add")
    public ModelAndView add(Integer type, String marketId, String propertyMgrId){
        ModelAndView modelAndView = new ModelAndView("park/add");
        modelAndView.addObject("type", type);
        modelAndView.addObject("marketId", marketId);
        modelAndView.addObject("propertyMgrId", propertyMgrId);
        return modelAndView;
    }

    @RequestMapping(value = "/modify")
    public ModelAndView modify(Park park){
        parkService.modify(park);
        return new ModelAndView("redirect:/park/");
    }
}